package br.com.tiespec.ejb.Dao;

import javax.ejb.Stateless;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import br.com.tiespec.model.Modelo.Plano;

@Stateless(mappedName = "PlanoDAO")
public class PlanoDAO extends DAO {

	private static final long serialVersionUID = 1L;

	public Plano selecionar(Long idClientePortal) {
		Plano pInstance = new Plano();
		try {
			begin();
			pInstance = (Plano) this.session.createCriteria(Plano.class)
					.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
					.createCriteria("configuracoes")
					.createCriteria("clientePortal")
					.add(Restrictions.eq("id", idClientePortal)).uniqueResult();
			commit();
			fecharConexao();
		} catch (Exception e){
			e.printStackTrace();
			fecharConexao();
		}
		return pInstance;
	}
}